home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / dos_win / winsock / maillist / 94-02.Z / 94-02 / text0283.txt < prev    next >
Encoding:
Text File  |  1994-02-28  |  3.6 KB  |  99 lines

  1. Gunnar.Sylthe@nsd.uib.no wrote:
  2. >
  3. >I have been trying to download the Chameleon evaluation copy from Netmanage, 
  4. >but the ftp connection from here to ftp.netmanage.com is just too slow.
  5.  
  6. It's not just you.  I left it going overnight and got only two of the four
  7. files.  If they are using their own products to run their ftp machine, this
  8. is not a good sign. 
  9.  
  10. -- 
  11.  
  12. ------------------------------------------------------
  13. Jack Hamilton      Postal: POB 281107 SF CA 94128  USA 
  14. jfh@netcom.com     Packet: kd6ttl@w6pw.#nocal.ca.us.na 
  15. From news@bigblue.oit.unc.edu Fri Feb 25 15:08:03 1994
  16. Received: from bigblue.oit.unc.edu by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  17.           id AA24113; Fri, 25 Feb 1994 10:27:35 -0500
  18. Received: by bigblue.oit.unc.edu (AIX 3.2/UCB 5.64/4.03)
  19.           id AA16627; Fri, 25 Feb 1994 10:24:57 -0500
  20. Received: from GATEWAY by bigblue with netnews
  21.     for winsock@sunsite.unc.edu (winsock@sunsite.unc.edu)
  22. To: winsock@sunsite.unc.edu
  23. Date: Fri, 25 Feb 1994 15:08:03 GMT
  24. From: snewton@oac.hsc.uth.tmc.edu (Steven E. Newton)
  25. Message-Id: <snewton.285.2D6E1453@oac.hsc.uth.tmc.edu>
  26. Organization: Academic Computing
  27. Sender: ses
  28. References: <2kjgf0$9fm@jaws.cs.hmc.edu>
  29. Subject: Re: Winsock API Ques--Dotted IP address from socket?
  30.  
  31. In article <2kjgf0$9fm@jaws.cs.hmc.edu> aoliver@muddcs.claremont.edu (Andy Oliver) writes:
  32. >     I am trying to find out the dotted IP address of the machine to which a
  33. >socket is connected.  My program listens for connection attempts and accepts
  34. >them, so I don't know the remote machine's address to begin with.  I can
  35. >call 'getpeername' and have it fill a sockaddr structure, but I don't know
  36. >where to go from there.  The sockaddr data structure consists of a family
  37. >field and a 14 byte address array according to the winsock header file.  I
  38. >have tried calling 'inet_ntoa' with the address array to no avail.
  39. >     Any ideas?
  40.  
  41.  
  42. Pretty boilerplate... this routine should work:
  43. /*
  44.  *  Code stolen from nntp.....
  45.  *
  46.  * inet_netnames -- return the network, subnet, and host names of
  47.  * our peer process for the Internet domain.
  48.  *
  49.  *      Parameters:     "sock" is our socket, which we don't need.
  50.  *                      "sin" is a pointer to the result of
  51.  *                      a getpeername() call.
  52.  *                      "host_name"
  53.  *                      is filled in by this routine with the
  54.  *                      corresponding ASCII names of our peer.
  55.  *      Returns:        Nothing.
  56.  *      Side effects:   None.
  57.  *
  58. */
  59.  
  60. inet_netnames(sock, sin, host_name)
  61.         int                     sock;
  62.         struct sockaddr_in      *sin;
  63.         char                    *host_name;
  64. {
  65.         u_long                  net_addr;
  66.         struct hostent          *hp;
  67.         struct netent           *np;
  68.  
  69.         net_addr = inet_netof(sin->sin_addr);   /* net_addr in host order */
  70.         np = getnetbyaddr(net_addr, AF_INET);
  71.  
  72.         hp = gethostbyaddr((char *) &sin->sin_addr.s_addr,
  73.                 sizeof (sin->sin_addr.s_addr), AF_INET);
  74.  
  75.         if (hp != NULL)
  76.                 (void) strcpy(host_name, hp->h_name);
  77.         else
  78.                 (void) strcpy(host_name, inet_ntoa(sin->sin_addr));
  79. }
  80.  
  81. Now, use it like this:
  82.  
  83. int sockfd
  84. struct sockaddr sa;
  85. int length;
  86. char host_name[256];
  87.  
  88. getpeername(sockfd, &sa, &length);
  89. inet_netnames(sockfd, &sa, host_name);
  90.  
  91.  
  92. +     +      +      +   |     snewton@oac.hsc.uth.tmc.edu
  93.       But if            |
  94.       I tried           |     Nobody else speaks for me,
  95.       I could           |     and I speak for no one else.
  96.       Destroy           |http://oac3.hsc.uth.tmc.edu/staff/snewton/index.html
  97.       Your Heart        |     +     +     +     +     +     +     +     +    +
  98.  
  99.